
#include "stdafx.h"
#include "Wt2Ct_Util.h"
#include <vcg/complex/algorithms/attribute_seam.h>


void Wt2Ct_Util::ConvertWt2Vt( CMeshModel* pMesh )
{
	if( !pMesh )
		return;

	CMeshO& m = pMesh->cm;
	pMesh->UpdateDataMask( CMeshModel::MM_VERTTEXCOORD );
	//m.vert.EnableTexCoord();
	vcg::tri::AttributeSeam::SplitVertex( m, ExtractVertex, CompareVertex);
}


void Wt2Ct_Util::ExtractVertex(const CMeshO & srcMesh, const CMeshO::FaceType & f, int whichWedge, const CMeshO & dstMesh, CMeshO::VertexType & v)
{
	(void)srcMesh;
	(void)dstMesh;
	// This is done to preserve every single perVertex property
	// perVextex Texture Coordinate is instead obtained from perWedge one.
	v.ImportData(*f.cV(whichWedge));
	v.T() = f.cWT(whichWedge);
}

bool Wt2Ct_Util::CompareVertex(const CMeshO & m, const CMeshO::VertexType & vA, const CMeshO::VertexType & vB)
{
	(void)m;
	return (vA.cT() == vB.cT());
}